package com.kfm.am.file;

import java.io.*;
import java.util.concurrent.Callable;

public class FileReadCallable implements Callable<Integer> {
    private File original;

    public FileReadCallable(File original) {
        this.original = original;
    }

    @Override
    public Integer call() throws Exception {
        try {
            BufferedReader reader = new BufferedReader(new FileReader(original));
            String str = "";
            int sum = 0;
            while ((str = reader.readLine()) != null) {
                sum += str.split(" ").length;

            }
            return sum;
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }
}
